<template>
  <div class="section-content form-content" id="studentsUpdate">
    <h2>修改学生</h2>
    <div class="content">
      <div class="content-info">
        <h3>修改数据</h3>
        <div>
          <div>
            <div class="content-row">
              <label>学生姓名：</label>
              <input
                class="form-input"
                v-model.lazy="student.name"
                type="text"
                id="updateStudentsName"
              />
            </div>
            <div class="content-row">
              <label>学生年龄：</label>
              <input
                class="form-input"
                v-model.lazy="student.age"
                type="text"
                id="updateStudentsAge"
              />
            </div>
            <div class="content-row">
              <label> 学生性别： </label>
              <label style="margin-right: 30px">
                <input
                  v-model.lazy="student.gender"
                  type="radio"
                  name="updateStudentsGender"
                  value="男"
                />
                男
              </label>
              <label>
                <input
                  v-model.lazy="student.gender"
                  type="radio"
                  name="updateStudentsGender"
                  value="女"
                />
                女
              </label>
            </div>
            <div class="content-row">
              <p>
                学生班级 ：<select
                  name=""
                  id="select01"
                  v-model.lazy="student.classesId"
                >
                  <option
                    v-for="item in classesdata"
                    :key="item._id"
                    :value="item._id"
                  >
                    {{ item.name }}
                  </option>
                </select>
              </p>
            </div>
            <div class="content-row">
              <label>上传照片：</label>
              <input type="file" />
            </div>
            <div class="content-row" style="margin-top: 50px">
              <label></label>
              <button class="blue" id="updateStudentsBtn" @click="myxg()">
                确认修改
              </button>
            </div>
          </div>
          <!-- 照片预览区域 -->
          <div class="right-info">
            <div class="image-frame">
              <!-- <img src="./images/default.jpeg" alt=""> -->
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import api from "../http/api";

import { createNamespacedHelpers } from "vuex";
const { mapActions } = createNamespacedHelpers("students");

export default {
  props: ["_id"],
  data() {
    return {
      student:[],
      classesdata: [],
    };
  },
  async mounted() {
    //  this.getclasses(this._id);
    const data = await this.getstudentbyId(this._id);
    if (data.code) {
      this.student = { ...data.data };
    }
    console.log(data);
  },
  methods: {
    ...mapActions(["getstudentbyId", "updateStudents"]),

    // async myxg() {
    //   console.log(this.updateStudents);

    //   const data = await this.updateStudents(this.student);
    //   if (data.code) {
    //     alert("修改成功");
    //     this.$router.push("/Home/liststudents");
    //   }
    },
    // async getstudentbyId() {
    //   const data = await api.students.getstudentbyId({
    //     _id: this._id,
    //   });
    //   console.log(data.code);
    //   if (data.code) {
    //     this.student = { ...data.data };
    //   }
    //   console.log(data);
    // },

    // async updateStudents() {
    //   console.log(this.student);
    //   const data = await api.students.updateStudents(this.student);
    //   console.log(data.code);
    //   if (data.code) {
    //     console.log(data);
    //   }
    // },

    //获取班级
    //  async getclasses() {
    //   //发送请求获取学生数据
    //   const data = await api.classes.getclasses();
    //   if (data.code) {
    //     this.classesdata = data.data.result;
    //   }
    // },
  // },
};
</script>

<style>
</style>